package api

import (
	"2301a/awesomeProjectday5/api/handler"
	"2301a/awesomeProjectday5/consts"
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
)

func LoadRouter(r *gin.Engine) {
	api := r.Group("api")
	{
		user := api.Group("user")
		{
			user.POST("/register", handler.Register)
			user.POST("/login", handler.Login)
		}
		goods := api.Group("goods")
		{
			goods.Use(jwt.JWTAuth(consts.JWT_KEY))
			goods.POST("/add", handler.AddGoods)         //添加
			goods.POST("/list", handler.ListGoods)       //列表
			goods.POST("/modify", handler.ModifyGoods)   //修改
			goods.POST("/details", handler.DetailsGoods) //详情
			goods.POST("/remove", handler.RemoveGoods)   //删除
		}
	}
}
